//
//  AppTabBarViewController.swift
//  SinaNews
//
//  Created by hroot on 15/8/13.
//  Copyright (c) 2015年 Lily. All rights reserved.
//

import UIKit

class AppTabBarViewController: UITabBarController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        creatViewControllers()
    }

    override func viewWillAppear(animated: Bool) {
        super.viewWillAppear(animated)
//        whichView()
    }
    func creatViewControllers() {
        let titleArray = ["新闻","图片","视频","我的"];
        let iconNormalArray = ["tabbar_news@2x","tabbar_picture@2x","tabbar_video@2x","tabbar_setting@2x"];
        let iconSelectedArray = ["tabbar_news_hl@2x","tabbar_picture_hl@2x","tabbar_video_hl@2x","tabbar_setting_hl@2x"];
        let vcNames = ["NewsViewController","PictureViewController","VideoViewController","MeTableViewController"];
        var vcArr = NSMutableArray()
        for (var i = 0; i < vcNames.count; i++) {
//            var vcClass: AnyClass! = NSClassFromString(vcNames[i])
//            var appViewController: AppContainerViewController = vcClass()
            var appViewController: UIViewController
            if ( i == 0) {
                appViewController = NewsViewController()
            } else if ( i == 1) {
                appViewController = PictureViewController()
            } else if ( i == 2) {
                appViewController = VideoViewController()
            } else {
                appViewController = MeTableViewController()
            }
            appViewController.title = titleArray[i]
            var nav = UINavigationController(rootViewController: appViewController)
            nav.tabBarItem!.image = UIImage(named: iconNormalArray[i])
            nav.tabBarItem!.selectedImage = UIImage(named: iconSelectedArray[i])
            vcArr.addObject(nav)
        }
        self.viewControllers = vcArr as [AnyObject];
    }


    
    
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
